// 自定义事件的三种方法
let myEvent = new Event('myEvent');

let myEvent = new CustomEvent('myEvent', {
  detail: {
    name: 'lindaidai'
  }
})

let myEvent = document.createEvent('CustomEvent');
myEvent.initEvent('myEvent', true, true)

// 监听事件
let btn = document.getElementsByTagName('button')[0]
btn.addEventListener('myEvent', function (e) {
  console.log(e)
  console.log(e.detail)
})

// 发送(触发)事件
btn.dispatchEvent(myEvent)
